import {defineStore} from "pinia";
import {computed, ref} from "vue";

export const useAuthStore = defineStore('auth', () => {
    const authList = ref([])

    function setAuthList(auths) {
        authList.value = auths
    }

    function hasAuth(name) {
        if (authList.value.length === 0) {
            return false
        }
        for (let i = 0; i < authList.value.length; i++) {
            if (authList.value[i].name === name) {
                return true
            }
        }
        return false
    }

    return {authList, hasAuth, setAuthList}
})